def generate_fibonacci(n):
    """生成前n个斐波那契数"""
    fib_sequence = []
    a, b = 0, 1
    
    for _ in range(n):
        fib_sequence.append(a)
        a, b = b, a + b
    
    return fib_sequence

if __name__ == "__main__":
    # 让用户输入要生成的斐波那契数的数量
    try:
        count = int(input("请输入要生成的斐波那契数的数量: "))
        if count <= 0:
            print("请输入一个正整数")
        else:
            fib_numbers = generate_fibonacci(count)
            print(f"前{count}个斐波那契数是:")
            print(fib_numbers)
    except ValueError:
        print("请输入有效的整数")
